//
// Created by liushuai on 2021/2/13.
//

#include "majorityElement.h"
int majorityElement(vector<int>& nums) {
    int current = nums[0];
    int count = 1;
    int max_count = -1;
    int maxValue = 0;
    for(int i=1;i<nums.size();i++){
        if(nums[i] == current)
            count+=1;
        else{
            --count;
            if(count<0){
                count = 1;
                current = nums[i];
            }
        }

    }
    return current;
}